import { getHomeLists, getNoticeLists, getNoticeDetailInfo } from './../../fetch/modules/home'

const state = {
    homeData: {},
    noticeLists: {},
    noticeDetail: {}
}

const actions = {
    FETCH_HOME_LISTS: ({ commit, state }) => {
        return getHomeLists().then(home => commit('GET_HOME_LISTS', { home }))
    },
    FETCH_NOTICE_LISTS: ({ commit, state }, opts) => {
        return getNoticeLists(opts).then(home => commit('GET_NOTICE_LISTS', { home }))
    },
    FETCH_NOTICE_DETAIL: ({ commit, state }, opts) => {
        return getNoticeDetailInfo(opts).then(home => commit('GET_NOTICE_DETAIL_BYID', { home }))
    },
}
const mutations = {
    GET_HOME_LISTS: (state, { home }) => {
        state.homeData = home.data;
    },
    GET_NOTICE_LISTS: (state, { home }) => {
        state.noticeLists = home.data;
    },
    GET_NOTICE_DETAIL_BYID: (state, { home }) => {
        state.noticeDetail = home.data;
    },
}

const getters = {
    getHomeLists(state) {
        return state.homeData
    },
    getNoticeLists(state) {
        return state.noticeLists
    },
    getNoticeDetailInfo(state) {
        return state.noticeDetail
    },
}

export default {
    state,
    actions,
    mutations,
    getters
}